// Copyright (c) 2023 Institute of Software, Chinese Academy of Sciences
// Ripple is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
//          http://license.coscl.org.cn/MulanPSL2
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.

package ripple.common.entity;

import java.util.Date;
import java.util.List;
import java.util.UUID;


public class ReformRequest extends AbstractMessage {

    public ReformRequest(UUID uuid, String type, Date lastUpdate, int lastUpdateServerId) {
        super(uuid, type, lastUpdate, lastUpdateServerId);
    }
//
//    public ReformRequest(Date lastUpdate, int lastUpdateServerId) {
//        this(UUID.randomUUID(), lastUpdate, lastUpdateServerId);
//    }

    public List<NodeMetadata> getNodeList() {
        return nodeList;
    }

    public void setNodeList(List<NodeMetadata> nodeList) {
        this.nodeList = nodeList;
    }

    private List<NodeMetadata> nodeList;

    public static ReformRequest prepare(UUID uuid, Date lastUpdate, int lastUpdateServerId) {
        return new ReformRequest(uuid, Constants.REFORM_PREPARE, lastUpdate, lastUpdateServerId);
    }

    public static ReformRequest prepare(Date lastUpdate, int lastUpdateServerId) {
        return new ReformRequest(UUID.randomUUID(), Constants.REFORM_PREPARE, lastUpdate, lastUpdateServerId);
    }

    public static ReformRequest propose(UUID uuid, Date lastUpdate, int lastUpdateServerId) {
        return new ReformRequest(uuid, Constants.REFORM_PROPOSE, lastUpdate, lastUpdateServerId);
    }

    public static ReformRequest propose(Date lastUpdate, int lastUpdateServerId) {
        return new ReformRequest(UUID.randomUUID(), Constants.REFORM_PROPOSE, lastUpdate, lastUpdateServerId);
    }

    public static ReformRequest commit(UUID uuid, Date lastUpdate, int lastUpdateServerId) {
        return new ReformRequest(uuid, Constants.REFORM_COMMIT, lastUpdate, lastUpdateServerId);
    }

    public static ReformRequest commit(Date lastUpdate, int lastUpdateServerId) {
        return new ReformRequest(UUID.randomUUID(), Constants.REFORM_COMMIT, lastUpdate, lastUpdateServerId);
    }

    public static ReformRequest deprecate(UUID uuid, Date lastUpdate, int lastUpdateServerId) {
        return new ReformRequest(uuid, Constants.REFORM_DEPRECATE, lastUpdate, lastUpdateServerId);
    }

    public static ReformRequest deprecate(Date lastUpdate, int lastUpdateServerId) {
        return new ReformRequest(UUID.randomUUID(), Constants.REFORM_DEPRECATE, lastUpdate, lastUpdateServerId);
    }
}